package com.oxy.util;

public class SysErrException extends RuntimeException {
	private static final long serialVersionUID = 3719471327718257042L;
	
	private int errCd = 0;
	private String msg = null;
	
	public SysErrException() {
		super();
		this.errCd = SysErrManager.ERRORS.UNKNOWN_ERR;
    	this.msg = "No Message";
    }

    public SysErrException(int errCd) {
    	super();
    	this.errCd = errCd;
    	this.msg = "No Message";
    }
    public SysErrException(int errCd, String message) {
    	super();
    	this.errCd = errCd;
    	this.msg = message;
    }

    public SysErrException(int errCd, Throwable cause) {
    	super(cause);
    	this.errCd = errCd;
    	this.msg = cause.getMessage();
    }
    public SysErrException(int errCd, String message, Throwable cause) {
    	super(cause);
    	this.errCd = errCd;
    	this.msg = message;
    }
    
    public int getErrorCode() {
    	return errCd;
    }
    public String getErrorCodeStr() {
    	return String.format("%05d", errCd);
    }
    
    public String getErrorDesc() {
    	return SysErrManager.ERRORS.getErrDesc(this.errCd);
    }
    
    @Override
    public String getMessage() {
    	return msg;
    }
    
    @Override
    public String toString() {
    	return "Error Code: "+getErrorCodeStr()+"\r\nDescription: "+getErrorDesc()+"\r\nMessage: "+getMessage();
    }
}
